﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Majoopic.Utility
{
    /// <summary>
    /// Utility for the files
    /// </summary>
    public static class FileUtility
    {
        public static List<string> GetAllImagesInDirectory(string directoryPath, string fileExtension, bool includeSubFolder)
        {
            if (string.IsNullOrWhiteSpace(directoryPath))
            {
                throw new ArgumentNullException("directoryPath", "The directory path is null or empty");
            }
            if (Directory.Exists(directoryPath))
            {
                return new List<string>(Directory.GetFiles(directoryPath, string.Format(".{0}", fileExtension), includeSubFolder ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly));
            }
            return null;
        }
    }
}
